#!perl
use strict;
use warnings;
use Data::Dump qw(dump);
use JavaScript::Minifier qw(minify);

sub createRelease {
	my $js = shift;
	(my $rjs = $js) =~ s/([^\\]+)\.js$/release\\$1.js/;
    print $rjs, "\n";
	if ( ! -e $rjs or (stat($js))[9] > (stat($rjs))[9]) {
		print "create releave version for :", $js, "\n";
		#open IN, $js or die "open file $js failed:$!";
		open OUT, ">$rjs" or die "open file $rjs failed:$!";
		#&minify(input => *IN, outfile => *OUT);
		#close IN;
		print OUT `java -jar  e:\\yuicompressor-2.3.4.jar --charset utf-8 --type js $js`;
		close OUT;
	}
}

my $workdir = ".";
opendir CDIR, $workdir or die "open dir $workdir failed:$!";
my @js = grep /\.js/, readdir CDIR;
closedir CDIR;
for my $js (@js) {
	createRelease $workdir . '\\' . $js;
}
`pause`;
